package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 新增菜品
     * @param dish
     */
    @AutoFill(value= OperationType.INSERT)
    void insert(Dish dish);


    /**
     * 菜品分页查询
     */
    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据id查询菜品表
     * @param id
     * @return
     */
    @Select("select * from dish where id=#{id}")
    Dish getbyId(Long id);

    /**
     * 根据菜品id查询口味数据
     * @param dishId
     * @return
     */
    @Select("select * from dish_flavor where dish_id=#{dishId} ")
    List<DishFlavor> getbydishId(Long dishId);


    /**
     * 根据菜品id删除菜品
     * @param id
     */
    @Delete("delete from dish where id=#{id}")
    void deleById(Long id);

    void deleteByIds(List<Long> ids);

    /**
     * 修改菜品表基本数据
     * @param dish
     */
    @AutoFill(value= OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 根据分类id查询菜品
     * @param dish
     * @return
     */
    List<Dish> list(Dish dish);
}
